package com.eshop.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.eshop.dao.WarningOperateDao;

public class WarningOperateServlet extends HttpServlet {

	public WarningOperateServlet() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String operate = request.getParameter("operate");
		String goodsId = request.getParameter("goodsId");
		WarningOperateDao dao = new WarningOperateDao();
		
		if("shlves".equals(operate))
		{
			String status = request.getParameter("status");
			int i = dao.warningShlves(status, goodsId);
		
		}
		
		if("delete".equals(operate))
		{
			dao.warningDelete(goodsId);
		}
		
		String type = request.getParameter("type");
		String brand = request.getParameter("brand");
		response.sendRedirect(request.getContextPath()+"/StockWarningServlet?type="+type+"&brand="+brand);
	}
}
